package com.jiazhong.front.controller;

import com.alibaba.fastjson.JSON;
import com.jiazhong.commons.Util.JsonResult;
import com.jiazhong.front.service.BookService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/book")
public class BookController {

    @Resource
    private BookService bookService;

    @GetMapping("/find_lower/{row}")
    public JsonResult findLowerBookDate(@PathVariable("row") int row){
        return bookService.findLowerBookData(row);
    }

    @GetMapping("/find_fresh/{row}")
    public JsonResult findFreshBook(@PathVariable("row") int row){
        return bookService.findFreshBookData(row);
    }

    @GetMapping("/find_more_category/{id}")
    public JsonResult findCategoryMore(@PathVariable("id") String id) {
        return bookService.findCategoryBookMoreData(id);
    }

    @GetMapping("/find_lower_more")
    public JsonResult findLowerMoreBook() {
        return bookService.findLowerBookMoreData();
    }

    @GetMapping("/find_fresh_more")
    public JsonResult findFreshMoreBook() {
        return bookService.findFreshBookMoreData();
    }

    @GetMapping("/find_search/{name}")
    public JsonResult findSearchBook(@PathVariable("name") String name){
        return bookService.findSearchBook(name);
    }

    @GetMapping("find_search_category/{cid}")
    public JsonResult findSearchCategoryBook(@PathVariable("name") String name,@PathVariable("cid") String cid){
        return bookService.findSearchCategoryBook(name, cid);
    }
}
